package com.qiaofang.repository;

import com.qiaofang.entity.Department;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DepartmentRepository extends JpaRepository<Department, Long> {

    @Query(value = "from Department d where d.merchantId in (:companyIds) and d.parentId = 0 and d.delFlag = 0 order by d.id asc ")
    List<Department> listTopDepartment(@Param(value = "companyIds") List<Long> companyIds);

}
